package com.sample.dubbo.demo.provider.impl;

import com.sample.dubbo.demo.api.CustomerService;
import com.sample.dubbo.demo.dto.Customer;
import com.sample.dubbo.demo.dto.QuerySchema;
import com.sample.dubbo.demo.provider.storage.CustomerRAMStorage;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service(timeout = 1000)
public class CustomerServiceImpl implements CustomerService {


    @Autowired
    CustomerRAMStorage storage;

    @Override
    public Customer save(Customer customer) {
        return storage.save(customer);
    }

    @Override
    public List<Customer> query(QuerySchema querySchema) {
        return storage.list();
    }

    @Override
    public Customer find(Long id) {
        return storage.get(id);
    }

    @Override
    public boolean delete(Long id) {
        return storage.delete(id);
    }
}
